/** 腾讯地图 */

const key = "B5EBZ-MORW6-DC3SD-EE7X6-GMPPV-7CFSN" //key
const sk = "B87tlEZL9ereSjdO9CFRgvZKS309Q" //Secret key


export default {
  sk,
  loadMap() {
    return new Promise((resolve, reject) => {
      if (document.getElementById("loadmap")) {
        return resolve(window.TMap);
      }
      window.mapCallback = function () {
        resolve(window.TMap);
      };

      let script = document.createElement("script");
      script.type = "text/javascript";
      script.async = true;
      script.id = "loadmap";
      script.src =`https://map.qq.com/api/gljs?&callback=mapCallback&libraries=tools,service&v=1.exp&key=${key}`;
      script.onerror = reject;
      document.head.appendChild(script);
    });
  }
};
